﻿<%@ Page Language="C#" MasterPageFile="~/masters/masterPage.Master" AutoEventWireup="true" CodeBehind="DeptMaster.aspx.cs" Inherits="balancescorecard.masters.DeptMaster" Title="Untitled Page" %>
<%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="dept_pk" 
    DataSourceID="DeptMasterDataSource" InsertItemPosition="LastItem" 
    oniteminserting="ListView1_ItemInserting">
    <ItemTemplate>
        <tr style="background-color:#DCDCDC;color: #000000;">
            <td>
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
            </td>
            <td>
                <asp:Label ID="dept_pkLabel" runat="server" Text='<%# Eval("dept_pk") %>' />
            </td>
            <td>
                <asp:CheckBox ID="dept_activeCheckBox" runat="server" 
                    Checked='<%# Eval("dept_active") %>' Enabled="false" />
            </td>
            <td>
                <asp:Label ID="dept_nameLabel" runat="server" Text='<%# Eval("dept_name") %>' />
            </td>
        </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
        <tr style="background-color:#FFF8DC;">
            <td>
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
            </td>
            <td>
                <asp:Label ID="dept_pkLabel" runat="server" Text='<%# Eval("dept_pk") %>' />
            </td>
            <td>
                <asp:CheckBox ID="dept_activeCheckBox" runat="server" 
                    Checked='<%# Eval("dept_active") %>' Enabled="false" />
            </td>
            <td>
                <asp:Label ID="dept_nameLabel" runat="server" Text='<%# Eval("dept_name") %>' />
            </td>
        </tr>
    </AlternatingItemTemplate>
    <EmptyDataTemplate>
        <table runat="server" 
            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
            <tr>
                <td>
                    No data was returned.</td>
            </tr>
        </table>
    </EmptyDataTemplate>
    <InsertItemTemplate>
        <tr style="">
            <td>
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                    Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Clear" />
            </td>
            <td>
                &nbsp;</td>
            <td>
                <asp:CheckBox ID="dept_activeCheckBox" runat="server" 
                    Checked='<%# Bind("dept_active") %>' />
            </td>
            <td>
                <asp:TextBox ID="dept_nameTextBox" runat="server" 
                    Text='<%# Bind("dept_name") %>' />
            </td>
        </tr>
    </InsertItemTemplate>
    <LayoutTemplate>
        <table runat="server">
            <tr runat="server">
                <td runat="server">
                    <table ID="itemPlaceholderContainer" runat="server" border="1" 
                        style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                        <tr runat="server" style="background-color:#DCDCDC;color: #000000;">
                            <th runat="server">
                            </th>
                            <th runat="server">
                                dept_pk</th>
                            <th runat="server">
                                dept_active</th>
                            <th runat="server">
                                dept_name</th>
                        </tr>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                    </table>
                </td>
            </tr>
            <tr runat="server">
                <td runat="server" 
                    style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                    <asp:DataPager ID="DataPager1" runat="server">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </td>
            </tr>
        </table>
    </LayoutTemplate>
    <EditItemTemplate>
        <tr style="background-color:#008A8C;color: #FFFFFF;">
            <td>
                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                    Text="Update" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Cancel" />
            </td>
            <td>
                <asp:Label ID="dept_pkLabel1" runat="server" Text='<%# Eval("dept_pk") %>' />
            </td>
            <td>
                <asp:CheckBox ID="dept_activeCheckBox" runat="server" 
                    Checked='<%# Bind("dept_active") %>' />
            </td>
            <td>
                <asp:TextBox ID="dept_nameTextBox" runat="server" 
                    Text='<%# Bind("dept_name") %>' />
            </td>
        </tr>
    </EditItemTemplate>
    <SelectedItemTemplate>
        <tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
            <td>
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
            </td>
            <td>
                <asp:Label ID="dept_pkLabel" runat="server" Text='<%# Eval("dept_pk") %>' />
            </td>
            <td>
                <asp:CheckBox ID="dept_activeCheckBox" runat="server" 
                    Checked='<%# Eval("dept_active") %>' Enabled="false" />
            </td>
            <td>
                <asp:Label ID="dept_nameLabel" runat="server" Text='<%# Eval("dept_name") %>' />
            </td>
        </tr>
    </SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="DeptMasterDataSource" runat="server" 
    ConnectionString="<%$ ConnectionStrings:balancescorecardConnectionString %>" 
    DeleteCommand="DELETE FROM [department] WHERE [dept_pk] = @dept_pk" 
    InsertCommand="INSERT INTO [department] ([dept_active], [dept_name]) VALUES (@dept_active, @dept_name)" 
    SelectCommand="SELECT [dept_pk], [dept_active], [dept_name] FROM [department]" 
    UpdateCommand="UPDATE [department] SET [dept_active] = @dept_active, [dept_name] = @dept_name WHERE [dept_pk] = @dept_pk">
    <DeleteParameters>
        <asp:Parameter Name="dept_pk" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="dept_active" Type="Boolean" />
        <asp:Parameter Name="dept_name" Type="String" />
        <asp:Parameter Name="dept_pk" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="dept_active" Type="Boolean" />
        <asp:Parameter Name="dept_name" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" DataSourceID="DeptMasterDataSource">
    </asp:GridView>
    <cc1:DynamicDataManager ID="DynamicDataManager1" runat="server" 
        AutoLoadForeignKeys="True" />
</asp:Content>
